package main

import (
	"context"
	"fmt"

	"github.com/apache/rocketmq-client-go/v2"
	"github.com/apache/rocketmq-client-go/v2/primitive"
	"github.com/apache/rocketmq-client-go/v2/producer"
)

func main() {
	nameServer, err := primitive.NewNamesrvAddr("29.2.198.24:9876")
	if err != nil {
		panic(err)
	}
	producer, err := rocketmq.NewProducer(
		producer.WithNameServer(nameServer),
		producer.WithGroupName("PG92861-001"),
	)
	if err != nil {
		panic(err)
	}
	producer.Start()
	defer producer.Shutdown()
	msg := &primitive.Message{
		Topic: "UFEP-TASK-MSG",
		Body:  []byte("Hello RocketMQ Golang Client"),
	}
	msg.WithTag("goLangTag")

	sr, err := producer.SendSync(context.TODO(), msg)
	if err != nil {
		panic(err)
	}
	fmt.Println("send message: ", sr.String())
}
